package org.cn.springcloudvv.timertask;

import lombok.extern.slf4j.Slf4j;
import org.cn.springcloudvv.base.AppContext;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import javax.annotation.PostConstruct;

/**
 *
 */
@Slf4j
@Service
public class CommonTimerTask {

    @Value("${commonTimerTask.run:true}")
    private boolean commonTimerTask_run;
	@Value("${app.environment:dev}")
	private String app_environment;
	@Value("${spring.application.name}")
	private String app_name;
	@Value("${server.port}")
	private String server_port;

	@PostConstruct
	public void init() {
		try {
			AppContext.app_environment = app_environment;
			AppContext.app_name = app_name;
			AppContext.server_port = server_port;
			AppContext.getLocalHostIp();
		}
		catch (Exception e)
		{
			log.error("commonTimerTask",e);
		}
	}

	public static void sleep(long ms) {
		try {
			Thread.sleep(ms);
		} catch (Exception e) {
		}
	}
}
